﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Subfaculty.Common.Entities;
using Subfaculty.WebApplication.ViewModels;

namespace Subfaculty.WebApplication.Translators
{
    public class StudyLoadOfTeacherTranslator : BaseTranslator<StudyLoad, StudyLoadTeacherViewModel>
    {
        public StudyLoadTeacherViewModel Translate(StudyLoad studyLoad, Teacher teacher)
        {
            var studyLoadTeacher = new StudyLoadTeacherViewModel()
            {
                Degree = teacher.Degree,
                Department = teacher.Department.Title,
                AcademicTitle = teacher.AcademicTitle,
                Name = teacher.Name,
                StudyYear = "c " + studyLoad.StudyYear.StartDate + " по " + studyLoad.StudyYear.EndDate
            };

            var teacherItems = (from item in studyLoad.LoadItems
                                where item.Teacher == teacher
                                select item).ToList();

            studyLoadTeacher.StudyLoadItems = new StudyLoadItemTranslator().MakeItems(teacherItems, studyLoad.StudyYear);

            return studyLoadTeacher;
        }
    }
}
